<a href="/order/complete?type=advance&oid=<?php echo $this->oid;?>" >
	<div class="topBack"><img src="/images/back_jiantou.png" style="width:40px;height:40px;"></div>
</a>
<div class="topContent" style="line-height:30px;">
	<p>我的地址</p>
	<p style="font-size:0.7em;line-height:0.1px;">微信安全支付</p>
</div>
<div class="topRight">&nbsp;</div>

<div id="wrapperAddressPresale" class="wrapperComman" style="top:40px;bottom:12px;">
<div style="width:100%;">
<div class="clear" style="padding:6px 0;background-color:#F2F2F2"></div>
<input type="hidden" id="sessionAddress" value="<?php echo $this->sessionAddress;?>">
<form>
	<div id="male">
			<?php 
				if(!empty($this->addressList)){
					foreach($this->addressList as $a){
						echo '
							 <div class="gouxuan" addressId="'.$a->id.'" contact="'.$a->contact.'" tel="'.$a->tel.'" address="'.$a->address.'" onclick="javascript:changeDefaultAddress(this);return false;">
								<label name="sex_male" id="icon'.$a->id.'" class="checkIcon" for="sex_male">1</label>
							</div>
							<div class="zitidian" addressId="'.$a->id.'" contact="'.$a->contact.'" tel="'.$a->tel.'" address="'.$a->address.'" onclick="javascript:changeDefaultAddress(this);return false;">
								<div class="zida">收货人：'.$a->contact.'</div><div class="zidatel">'.$a->tel.'</div>
								<div class="clear"></div>
								<div class="zixiao">'.$a->address.'</div>
							</div>
							<div class="delete"><!--<img src="/images/delete.png"/>--></div>
							<div class="clear"></div>
						';
					}
				}
			?>
	</div>
</form>
<div class="clear" ></div>
<a href="/address/editpresale?oid=<?php echo $this->oid;?>"><div class="posifix">新增地址</div></a>
</div>
</div>

<script type="text/javascript">
	$(document).ready(function(){
		var sessionAddress = $('#sessionAddress').val();
		$('#icon'+sessionAddress).addClass('checked');
		var myScroll;
		myScroll = new iScroll('wrapperAddressPresale');
	});

	function changeDefaultAddress(el){
		
		var addressId = $(el).attr('addressId');
		var contact = $(el).attr('contact');
		var tel = $(el).attr('tel');
		var address = $(el).attr('address');
		if(!isNull(addressId)){
			$.ajax({
				type: "post",
				url : "/address/presale",
				dataType:'json',
				data:{'addressId':addressId,'contact':contact,'tel':tel,'address':address},
				success: function(info){
					$('.checkIcon').removeClass('checked');
					$('#icon'+addressId).addClass('checked');
					location.href='/order/complete?type=advance&oid=<?php echo $this->oid;?>';
				},
				error: function(){
				}
			});
		}
	}
 </script>
